﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Jbe.TestSuite.Infrastructure.Interface;
using Jbe.TestSuite.TestDevices.FunctionGenerator.Interface;
using Jbe.Composite.Extensions;
using System.Windows.Input;

namespace Jbe.TestSuite.TestDevices.FunctionGenerator.ControlView.Applications
{
    internal class ConfigurationEditPresentationModel : PresentationModel<IConfigurationEditView>
    {
        private readonly DelegateCommand acceptCommand;
        private readonly DelegateCommand cancelCommand;
        private readonly IFunctionGeneratorConfig config;
        private readonly string title;
        private bool result;


        public ConfigurationEditPresentationModel(IConfigurationEditView view, IFunctionGeneratorConfig config, string title)
            : base(view)
        {
            this.acceptCommand = new DelegateCommand(OK);
            this.cancelCommand = new DelegateCommand(Cancel);
            this.config = config;
            this.title = title;

            ConfigurationPresentationModel configPresentationModel = new ConfigurationPresentationModel(View.ConfigurationView);
            configPresentationModel.Config = config;
        }


        public ICommand AcceptCommand { get { return acceptCommand; } }

        public ICommand CancelCommand { get { return cancelCommand; } }

        public IFunctionGeneratorConfig Config { get { return config; } }

        public string Title { get { return title; } }


        public bool? ShowDialog()
        {
            View.ShowDialog();
            return result;
        }

        private void OK()
        {
            result = true;
            View.Close();
        }

        private void Cancel()
        {
            View.Close();
        }
    }
}
